#ifndef __AS_LIST_ITEM__H__
#define __AS_LIST_ITEM__H__

#include "ASControl.h"
#include "ASImage.h"

#define AS_LIST_ITEM_MAX_CONTROLS 8

struct _as_listitem;
typedef struct _as_listitem as_listitem;

typedef void (*as_listitem_cb)(as_listitem* item_p);

struct _as_listitem
{
    /* base */
    as_control base;

    /* attributes */
    ASINT is_selected;
    ASINT could_selected;
    ASINT cur_ctrl_counts;
    as_image* bg_img;
    as_image* bg_selected_img;
    ASUINT bg_color;
    ASUINT bg_selected_color;
    as_control* ctrls[AS_LIST_ITEM_MAX_CONTROLS];//manager it as a list
    as_listitem* prev_p;//for list
    as_listitem* next_p;//for list
    as_rect father_area;//store the area of list
    as_listitem_cb pen_down_cb;
    as_listitem_cb pen_up_cb;

    /* methods */
    as_ret (*set_bg_color)(as_control* ctrl_p, ASUINT color);
    as_ret (*set_bg_selected_color)(as_control* ctrl_p, ASUINT color);
    as_ret (*set_bg_image)(as_control* ctrl_p, ASWSTR path, as_image_src_type type);
    as_ret (*set_bg_selected_image)(as_control* ctrl_p, ASWSTR path, as_image_src_type type);
    as_control* (*get_ctrl_by_type)(as_control* father_p, as_control_type type);
    ASINT (*get_cur_ctrl_counts)(as_control* father_p);
    as_control* (*add_ctrl)(as_control* father_p, as_control_type type, as_rect area, ASINT extra_param_cnts, void** extra_param_p);
    as_ret (*delete_ctrl)(as_control* father_p, as_control* ctrl_p);
    as_ret (*clear_ctrls)(as_control* father_p);
    as_ret (*set_focus)(as_control* father_p, ASINT if_focus);
    ASINT (*get_focus)(as_control* father_p);
    as_ret (*set_prev_item)(as_control* ctrl_p, as_listitem* prev_p);
    as_ret (*set_next_item)(as_control* ctrl_p, as_listitem* next_p);
    as_listitem* (*get_prev_item)(as_control* ctrl_p);
    as_listitem* (*get_next_item)(as_control* ctrl_p);
    as_ret (*save_father_area)(as_control* ctrl_p, as_rect* area_p);
    void (*set_pen_down_cb)(as_control* ctrl_p, as_listitem_cb cb);
    void (*set_pen_up_cb)(as_control* ctrl_p, as_listitem_cb cb);
    void (*paint_bg)(as_control* ctrl_p);
    as_ret (*set_if_could_select)(as_control* ctrl_p, ASINT if_could);
};


as_listitem* as_ctrl_listitem_create(as_rect area, as_rect* father_area_p);


as_ret as_ctrl_listitem_destroy(as_listitem* ctrl_listitem_p);


#endif//__AS_LIST_ITEM__H__